package com.weixiao.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//布隆过滤器
@Configuration
public class MyRBLoomFilter {
    @Autowired
    private RedissonClient redissonClient;

    @Bean
    public RBloomFilter<String> rBloomFilter() {
        RBloomFilter<String> bloomFilter = redissonClient.getBloomFilter("seckill-bloom");
        //设置预期最大数跟误差率
        bloomFilter.tryInit(1000000, 00000.1);
        return bloomFilter;
    }
}
